from ..func.erase_func import EraseInFunctions


def erase_in(clip, anchor="E", duration=None):
    """

    :param clip:
    :param anchor:
              +------+------+------+
              | ' ' | 'N'  | ' ' |
              +------+------+------+
              | 'W'  | 'C' 'OC'| ' E' |
              +------+------+------+
              | ' ' | 'S'  | ' ' |
              +------+------+------+
    :param duration:
    :param padding_duration:
    :return:
    """
    if duration is None:
        duration = clip.duration
    func = None
    if anchor in ['E', 'W', 'N', 'S']:
        func = EraseInFunctions.direction(duration, clip.duration, anchor)
    elif anchor in ["C", "OC"]:
        func = EraseInFunctions.cross(duration, clip.duration, anchor)
    return clip.fl(func, apply_to=["mask"])
